/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author breinesg
 */
@Entity
@Table(name = "MEDIUM")
@XmlRootElement
@Inheritance(strategy= InheritanceType.JOINED)
@DiscriminatorColumn(name="discriminator")
@NamedQueries({
    @NamedQuery(name = "Medium.findAll", query = "SELECT m FROM Medium m"),
    @NamedQuery(name = "Medium.findByMediumId", query = "SELECT m FROM Medium m WHERE m.mediumId = :mediumId"),
    @NamedQuery(name = "Medium.findByTitle", query = "SELECT m FROM Medium m WHERE m.title = :title"),
    @NamedQuery(name = "Medium.findByDiscriminator", query = "SELECT m FROM Medium m WHERE m.discriminator = :discriminator")})
public abstract class Medium implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "MEDIUM_ID")
    protected Integer mediumId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "TITLE")
    private String title;
    @Size(max = 5)
    @Column(name = "DISCRIMINATOR")
    private String discriminator;
    @JoinColumn(name = "SHELF_ID", referencedColumnName = "SHELF_ID")
    @ManyToOne(optional = false)
    private Shelf shelfId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "mediumId")
    private List<Exemplar> exemplarList;

    public Medium() {
    }

    public Medium(Integer mediumId) {
        this.mediumId = mediumId;
    }

    public Medium(Integer mediumId, String title) {
        this.mediumId = mediumId;
        this.title = title;
    }

    public Integer getMediumId() {
        return mediumId;
    }

    public void setMediumId(Integer mediumId) {
        this.mediumId = mediumId;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDiscriminator() {
        return discriminator;
    }

    public void setDiscriminator(String discriminator) {
        this.discriminator = discriminator;
    }
    public Shelf getShelfId() {
        return shelfId;
    }

    public void setShelfId(Shelf shelfId) {
        this.shelfId = shelfId;
    }

    @XmlTransient
    public List<Exemplar> getExemplarList() {
        return exemplarList;
    }

    public void setExemplarList(List<Exemplar> exemplarList) {
        this.exemplarList = exemplarList;
    }
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (mediumId != null ? mediumId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Medium)) {
            return false;
        }
        Medium other = (Medium) object;
        if ((this.mediumId == null && other.mediumId != null) || (this.mediumId != null && !this.mediumId.equals(other.mediumId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "persistence.Medium[ mediumId=" + mediumId + " ]";
    }
    
}
